#include<iostream>
#include<thread>
#include<mutex>
using namespace std; 
int main()
{
	int n = 100;
	mutex mtx1, mtx2;
	condition_variable cv1, cv2;
	thread t1([&]() {
		for (int i = 0; i < n; i += 2) {
			cv1.wait(unique_lock<mutex>(mtx1));
			/*if (i & 1) {
				cout << this_thread::get_id() << " " << i << endl;
			}*/
			cout << this_thread::get_id() << " " << i << endl;
			cv2.notify_one();
		}
		});
	thread t2([&]() {
		for (int i = 1; i < n; i += 2) {
			/*if (!(i & 1)) {
				cout << this_thread::get_id() << " " << i << endl;
			}*/
			cout << this_thread::get_id() << " " << i << endl;
		}
		});

	t1.join();
	t2.join();
	
	
	return 0;
}